// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Ccr
{
	public sealed class CcrPutAutoFollowPatternRequestParameters : RequestParameters<CcrPutAutoFollowPatternRequestParameters>
	{
	}

	public sealed partial class CcrPutAutoFollowPatternRequest : PlainRequestBase<CcrPutAutoFollowPatternRequestParameters>
	{
		public CcrPutAutoFollowPatternRequest(Elastic.Clients.Elasticsearch.Name name) : base(r => r.Required("name", name))
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.CrossClusterReplicationPutAutoFollowPattern;
		protected override HttpMethod HttpMethod => HttpMethod.PUT;
		protected override bool SupportsBody => true;
		[JsonInclude]
		[JsonPropertyName("remote_cluster")]
		public string RemoteCluster { get; set; }

		[JsonInclude]
		[JsonPropertyName("follow_index_pattern")]
		public string? FollowIndexPattern { get; set; }

		[JsonInclude]
		[JsonPropertyName("leader_index_patterns")]
		public IEnumerable<string>? LeaderIndexPatterns { get; set; }

		[JsonInclude]
		[JsonPropertyName("leader_index_exclusion_patterns")]
		public IEnumerable<string>? LeaderIndexExclusionPatterns { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_outstanding_read_requests")]
		public int? MaxOutstandingReadRequests { get; set; }

		[JsonInclude]
		[JsonPropertyName("settings")]
		public Dictionary<string, object>? Settings { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_outstanding_write_requests")]
		public int? MaxOutstandingWriteRequests { get; set; }

		[JsonInclude]
		[JsonPropertyName("read_poll_timeout")]
		public Elastic.Clients.Elasticsearch.Duration? ReadPollTimeout { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_read_request_operation_count")]
		public int? MaxReadRequestOperationCount { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_read_request_size")]
		public Elastic.Clients.Elasticsearch.ByteSize? MaxReadRequestSize { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_retry_delay")]
		public Elastic.Clients.Elasticsearch.Duration? MaxRetryDelay { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_write_buffer_count")]
		public int? MaxWriteBufferCount { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_write_buffer_size")]
		public Elastic.Clients.Elasticsearch.ByteSize? MaxWriteBufferSize { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_write_request_operation_count")]
		public int? MaxWriteRequestOperationCount { get; set; }

		[JsonInclude]
		[JsonPropertyName("max_write_request_size")]
		public Elastic.Clients.Elasticsearch.ByteSize? MaxWriteRequestSize { get; set; }
	}

	public sealed partial class CcrPutAutoFollowPatternRequestDescriptor : RequestDescriptorBase<CcrPutAutoFollowPatternRequestDescriptor, CcrPutAutoFollowPatternRequestParameters>
	{
		internal CcrPutAutoFollowPatternRequestDescriptor(Action<CcrPutAutoFollowPatternRequestDescriptor> configure) => configure.Invoke(this);
		public CcrPutAutoFollowPatternRequestDescriptor(Elastic.Clients.Elasticsearch.Name name) : base(r => r.Required("name", name))
		{
		}

		internal CcrPutAutoFollowPatternRequestDescriptor()
		{
		}

		internal override ApiUrls ApiUrls => ApiUrlsLookups.CrossClusterReplicationPutAutoFollowPattern;
		protected override HttpMethod HttpMethod => HttpMethod.PUT;
		protected override bool SupportsBody => true;
		public CcrPutAutoFollowPatternRequestDescriptor Name(Elastic.Clients.Elasticsearch.Name name)
		{
			RouteValues.Required("name", name);
			return Self;
		}

		private string? FollowIndexPatternValue { get; set; }

		private IEnumerable<string>? LeaderIndexExclusionPatternsValue { get; set; }

		private IEnumerable<string>? LeaderIndexPatternsValue { get; set; }

		private int? MaxOutstandingReadRequestsValue { get; set; }

		private int? MaxOutstandingWriteRequestsValue { get; set; }

		private int? MaxReadRequestOperationCountValue { get; set; }

		private Elastic.Clients.Elasticsearch.ByteSize? MaxReadRequestSizeValue { get; set; }

		private Elastic.Clients.Elasticsearch.Duration? MaxRetryDelayValue { get; set; }

		private int? MaxWriteBufferCountValue { get; set; }

		private Elastic.Clients.Elasticsearch.ByteSize? MaxWriteBufferSizeValue { get; set; }

		private int? MaxWriteRequestOperationCountValue { get; set; }

		private Elastic.Clients.Elasticsearch.ByteSize? MaxWriteRequestSizeValue { get; set; }

		private Elastic.Clients.Elasticsearch.Duration? ReadPollTimeoutValue { get; set; }

		private string RemoteClusterValue { get; set; }

		private Dictionary<string, object>? SettingsValue { get; set; }

		public CcrPutAutoFollowPatternRequestDescriptor FollowIndexPattern(string? followIndexPattern)
		{
			FollowIndexPatternValue = followIndexPattern;
			return Self;
		}

		public CcrPutAutoFollowPatternRequestDescriptor LeaderIndexExclusionPatterns(IEnumerable<string>? leaderIndexExclusionPatterns)
		{
			LeaderIndexExclusionPatternsValue = leaderIndexExclusionPatterns;
			return Self;
		}

		public CcrPutAutoFollowPatternRequestDescriptor LeaderIndexPatterns(IEnumerable<string>? leaderIndexPatterns)
		{
			LeaderIndexPatternsValue = leaderIndexPatterns;
			return Self;
		}

		public CcrPutAutoFollowPatternRequestDescriptor MaxOutstandingReadRequests(int? maxOutstandingReadRequests)
		{
			MaxOutstandingReadRequestsValue = maxOutstandingReadRequests;
			return Self;
		}

		public CcrPutAutoFollowPatternRequestDescriptor MaxOutstandingWriteRequests(int? maxOutstandingWriteRequests)
		{
			MaxOutstandingWriteRequestsValue = maxOutstandingWriteRequests;
			return Self;
		}

		public CcrPutAutoFollowPatternRequestDescriptor MaxReadRequestOperationCount(int? maxReadRequestOperationCount)
		{
			MaxReadRequestOperationCountValue = maxReadRequestOperationCount;
			return Self;
		}

		public CcrPutAutoFollowPatternRequestDescriptor MaxReadRequestSize(Elastic.Clients.Elasticsearch.ByteSize? maxReadRequestSize)
		{
			MaxReadRequestSizeValue = maxReadRequestSize;
			return Self;
		}

		public CcrPutAutoFollowPatternRequestDescriptor MaxRetryDelay(Elastic.Clients.Elasticsearch.Duration? maxRetryDelay)
		{
			MaxRetryDelayValue = maxRetryDelay;
			return Self;
		}

		public CcrPutAutoFollowPatternRequestDescriptor MaxWriteBufferCount(int? maxWriteBufferCount)
		{
			MaxWriteBufferCountValue = maxWriteBufferCount;
			return Self;
		}

		public CcrPutAutoFollowPatternRequestDescriptor MaxWriteBufferSize(Elastic.Clients.Elasticsearch.ByteSize? maxWriteBufferSize)
		{
			MaxWriteBufferSizeValue = maxWriteBufferSize;
			return Self;
		}

		public CcrPutAutoFollowPatternRequestDescriptor MaxWriteRequestOperationCount(int? maxWriteRequestOperationCount)
		{
			MaxWriteRequestOperationCountValue = maxWriteRequestOperationCount;
			return Self;
		}

		public CcrPutAutoFollowPatternRequestDescriptor MaxWriteRequestSize(Elastic.Clients.Elasticsearch.ByteSize? maxWriteRequestSize)
		{
			MaxWriteRequestSizeValue = maxWriteRequestSize;
			return Self;
		}

		public CcrPutAutoFollowPatternRequestDescriptor ReadPollTimeout(Elastic.Clients.Elasticsearch.Duration? readPollTimeout)
		{
			ReadPollTimeoutValue = readPollTimeout;
			return Self;
		}

		public CcrPutAutoFollowPatternRequestDescriptor RemoteCluster(string remoteCluster)
		{
			RemoteClusterValue = remoteCluster;
			return Self;
		}

		public CcrPutAutoFollowPatternRequestDescriptor Settings(Func<FluentDictionary<string, object>, FluentDictionary<string, object>> selector)
		{
			SettingsValue = selector?.Invoke(new FluentDictionary<string, object>());
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			if (FollowIndexPatternValue is not null)
			{
				writer.WritePropertyName("follow_index_pattern");
				JsonSerializer.Serialize(writer, FollowIndexPatternValue, options);
			}

			if (LeaderIndexExclusionPatternsValue is not null)
			{
				writer.WritePropertyName("leader_index_exclusion_patterns");
				JsonSerializer.Serialize(writer, LeaderIndexExclusionPatternsValue, options);
			}

			if (LeaderIndexPatternsValue is not null)
			{
				writer.WritePropertyName("leader_index_patterns");
				JsonSerializer.Serialize(writer, LeaderIndexPatternsValue, options);
			}

			if (MaxOutstandingReadRequestsValue.HasValue)
			{
				writer.WritePropertyName("max_outstanding_read_requests");
				writer.WriteNumberValue(MaxOutstandingReadRequestsValue.Value);
			}

			if (MaxOutstandingWriteRequestsValue.HasValue)
			{
				writer.WritePropertyName("max_outstanding_write_requests");
				writer.WriteNumberValue(MaxOutstandingWriteRequestsValue.Value);
			}

			if (MaxReadRequestOperationCountValue.HasValue)
			{
				writer.WritePropertyName("max_read_request_operation_count");
				writer.WriteNumberValue(MaxReadRequestOperationCountValue.Value);
			}

			if (MaxReadRequestSizeValue is not null)
			{
				writer.WritePropertyName("max_read_request_size");
				JsonSerializer.Serialize(writer, MaxReadRequestSizeValue, options);
			}

			if (MaxRetryDelayValue is not null)
			{
				writer.WritePropertyName("max_retry_delay");
				JsonSerializer.Serialize(writer, MaxRetryDelayValue, options);
			}

			if (MaxWriteBufferCountValue.HasValue)
			{
				writer.WritePropertyName("max_write_buffer_count");
				writer.WriteNumberValue(MaxWriteBufferCountValue.Value);
			}

			if (MaxWriteBufferSizeValue is not null)
			{
				writer.WritePropertyName("max_write_buffer_size");
				JsonSerializer.Serialize(writer, MaxWriteBufferSizeValue, options);
			}

			if (MaxWriteRequestOperationCountValue.HasValue)
			{
				writer.WritePropertyName("max_write_request_operation_count");
				writer.WriteNumberValue(MaxWriteRequestOperationCountValue.Value);
			}

			if (MaxWriteRequestSizeValue is not null)
			{
				writer.WritePropertyName("max_write_request_size");
				JsonSerializer.Serialize(writer, MaxWriteRequestSizeValue, options);
			}

			if (ReadPollTimeoutValue is not null)
			{
				writer.WritePropertyName("read_poll_timeout");
				JsonSerializer.Serialize(writer, ReadPollTimeoutValue, options);
			}

			writer.WritePropertyName("remote_cluster");
			writer.WriteStringValue(RemoteClusterValue);
			if (SettingsValue is not null)
			{
				writer.WritePropertyName("settings");
				JsonSerializer.Serialize(writer, SettingsValue, options);
			}

			writer.WriteEndObject();
		}
	}
}